﻿#include "../lv_Agriculture.h"

static void lv_Setting_Content(lv_obj_t *parent);
void lv_SettingExit_Btn(lv_obj_t *parent);
void lv_SettingExit_Btn_Callback(lv_event_t *e);
lv_obj_t *lv_Setting_Screen;
lv_group_t *set_group;
void lv_Setting_Page(void)
{
    lv_Setting_Screen = lv_obj_create(NULL);
    lv_obj_add_style(lv_Setting_Screen, &lv_Clean_Style, LV_STATE_DEFAULT);
    lv_obj_clear_flag(lv_Setting_Screen, LV_OBJ_FLAG_SCROLLABLE);
    lv_obj_set_size(lv_Setting_Screen, 320, 240);

    lv_Top_StateBar(lv_Setting_Screen); // 顶部状态栏
    lv_Setting_Content(lv_Setting_Screen);
    lv_SettingExit_Btn(lv_Setting_Screen); // 返回按钮
}

static void lv_Setting_Content(lv_obj_t *parent)
{
    lv_obj_t *Setting_Content = lv_obj_create(parent);
    lv_obj_add_style(Setting_Content, &lv_Clean_Style, LV_STATE_DEFAULT);
    lv_obj_set_align(Setting_Content, LV_ALIGN_BOTTOM_MID);
    lv_obj_set_size(Setting_Content, lv_pct(100), lv_pct(85));
    lv_obj_set_flex_flow(Setting_Content, LV_FLEX_FLOW_COLUMN);
    lv_obj_set_flex_align(Setting_Content, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);

    set_group = lv_group_create();
    lv_indev_set_group(indev_keypad,set_group);
    lv_obj_t *list = lv_list_create(Setting_Content);
    lv_obj_set_size(list, lv_pct(100), lv_pct(100));

    lv_obj_t *WIFI_Item = lv_list_add_btn(list, LV_SYMBOL_WIFI, "WIFI");
    lv_obj_add_event_cb(WIFI_Item, List_Callback, LV_EVENT_PRESSED, NULL);

    lv_list_add_btn(list, LV_SYMBOL_CLOSE, "Close");
    lv_list_add_btn(list, LV_SYMBOL_EYE_OPEN, "Show");
    lv_list_add_btn(list, LV_SYMBOL_EYE_CLOSE, "Hide");
    lv_list_add_btn(list, LV_SYMBOL_TRASH, "Delete");
    lv_list_add_btn(list, LV_SYMBOL_COPY, "Copy");
    lv_list_add_btn(list, LV_SYMBOL_PASTE, "Paste");

    lv_group_add_obj(set_group, WIFI_Item);
}

void lv_SettingExit_Btn(lv_obj_t *parent)
{
    lv_obj_t *Exit_Btn = lv_btn_create(parent);
    lv_obj_t *Exit_Label = lv_label_create(Exit_Btn);
    lv_label_set_text(Exit_Label, LV_SYMBOL_LEFT);
    lv_obj_set_align(Exit_Btn, LV_ALIGN_BOTTOM_LEFT);
    lv_obj_add_event_cb(Exit_Btn, lv_SettingExit_Btn_Callback, LV_EVENT_ALL, NULL);
    lv_group_add_obj(set_group, Exit_Btn);
}

void lv_SettingExit_Btn_Callback(lv_event_t *e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t *target = lv_event_get_target(e);

    lv_GotoScreenTypeDef *GotoScreenStruct = (lv_GotoScreenTypeDef *)lv_event_get_user_data(e);
    if (event_code == LV_EVENT_CLICKED)
    {
        lv_Home_Page();
        lv_scr_load_anim(lv_Home_Screen, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, false);
    }
}
